package com.hongshu.web.service.recommendation.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * 召回结果模型
 * 
 * @author hongshu
 * @date 2024/01/01
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RecallResult {
    
    private Set<String> candidateItems;
    private Map<String, Double> itemScores;
    
    /**
     * 获取物品ID列表
     */
    public Set<String> getItemIds() {
        return candidateItems != null ? candidateItems : new HashSet<>();
    }
    
    /**
     * 获取物品分数映射
     */
    public Map<String, Double> getItemScores() {
        return itemScores != null ? itemScores : new HashMap<>();
    }
    
    /**
     * 默认召回结果
     */
    public static RecallResult empty() {
        return RecallResult.builder()
            .candidateItems(new HashSet<>())
            .itemScores(new HashMap<>())
            .build();
    }
}


